package net.wwang.open.pojo;

import net.wwang.open.global.GlobalTipMsg;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.sql.Timestamp;

/**
 * @author WangWei
 * @date 2020/8/11
 */
@Entity
@Data
@Table(name = "menu")
@NoArgsConstructor
@AllArgsConstructor
public class Menu {

    @Id
    @Column(name = "id")
    private String id;
    @NotBlank(message = GlobalTipMsg.MENUNAME_NOT_EMPTY)
    @Size(max = 32,message = GlobalTipMsg.MENU_NAME_TOO_LONG)
    @Pattern(regexp = "[^%&',;=?$\\x22]+",message = GlobalTipMsg.MENU_NAME_EXISTS_SPECIAL_CHARACTERS)
    @Column(name = "name")
    private String name;
    @NotBlank(message = GlobalTipMsg.MENU_PARENT_NOT_EMPTY)
    @Column(name = "parent_id")
    private String parentId;
    @Pattern(regexp = "^0|1$",message = GlobalTipMsg.MENU_TYPE_ERROR)
    @Column(name = "type")
    private String type;
    @NotBlank(message = GlobalTipMsg.MENU_SPACE_NOT_EMPTY)
    @Column(name = "space")
    private String space;
    @Column(name = "create_time")
    private Timestamp createTime;
    @Column(name = "update_time")
    private Timestamp updateTime;
}
